use "/Users/spencerpiston/Dropbox/Data/ANES/ANES 2016/anes_timeseries_2016.dta", clear

*weight
gen weightfull=V160102

*whites work together - how important is it that whites work together to change laws unfair to whites
gen wwt=.
replace wwt=V162316 if V162316>0
replace wwt=((wwt*-1)+5)/4
tab wwt

*whites unable to find job because hiring minorities instead
gen wutfj=.
replace wutfj=V162317 if V162317>0
replace wutfj=((wutfj*-1)+5)/4
tab wutfj

*government treats blacks better than whites
gen gtbb=.
replace gtbb=7 if V162318==3 & V162319==1
replace gtbb=6 if V162318==3 & V162319==2
replace gtbb=5 if V162318==3 & V162319==3
replace gtbb=4 if V162318==2
replace gtbb=3 if V162318==1 & V162319==3
replace gtbb=2 if V162318==1 & V162319==2
replace gtbb=1 if V162318==1 & V162319==1
replace gtbb=(gtbb-1)/6

*police treat blacks better than whites
gen ptbb=.
replace ptbb=7 if V162320==3 & V162321==1
replace ptbb=6 if V162320==3 & V162321==2
replace ptbb=5 if V162320==3 & V162321==3
replace ptbb=4 if V162320==2
replace ptbb=3 if V162320==1 & V162321==3
replace ptbb=2 if V162320==1 & V162321==2
replace ptbb=1 if V162320==1 & V162321==1
replace ptbb=(ptbb-1)/6

*White (non-Hispanic)
gen white=0
recode white 0=1 if V161310x==1

*HS 
gen hs=.
replace hs=0 if V161270>=1 & V161270<=8
replace hs=0 if V161270>=10 & V161270<=16
replace hs=1 if V161270==9
replace hs=1 if V161270==90
tab hs V161270, miss

*Some College
gen somecollege=.
replace somecollege=0 if V161270>=1 & V161270<=9
replace somecollege=0 if V161270>=13 & V161270<=90
replace somecollege=1 if V161270>=10 & V161270<=12
tab somecollege V161270, miss
gen sc=somecollege

*College Plus
gen collegeplus=.
replace collegeplus=0 if V161270>=1 & V161270<=12
replace collegeplus=0 if V161270==90
replace collegeplus=1 if V161270>=13 & V161270<=16
tab collegeplus V161270, miss
gen cp=collegeplus

lab var hs "High School Grad"
lab var sc "Some College"
lab var cp "College Plus"

svyset [pweight=weightfull]
xi: eststo Whites2016: svy, subpop(white): reg wwt hs sc cp
coefplot (Whites2016, label(Whites)), drop(_cons) xline(0) title("Whites Work Together")
graph save graph1, replace

svyset [pweight=weightfull]
xi: eststo Whites2016: svy, subpop(white): reg wutfj hs sc cp
coefplot (Whites2016, label(Whites)), drop(_cons) xline(0) title("Whites Unable to Find Job")
graph save graph2, replace

svyset [pweight=weightfull]
xi: eststo Whites2016: svy, subpop(white): reg gtbb hs sc cp
coefplot (Whites2016, label(Whites)), drop(_cons) xline(0) title("Govt Treats Whites Worse")
graph save graph3, replace

svyset [pweight=weightfull]
xi: eststo Whites2016: svy, subpop(white): reg ptbb hs sc cp
coefplot (Whites2016, label(Whites)), drop(_cons) xline(0) title("Police Treat Whites Worse")
graph save graph4, replace

graph combine graph1.gph graph2.gph graph3.gph graph4.gph, graphregion( color(white) ) title("")
